package com.zzyl.member.controller;

import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.core.page.TableDataInfo;
import com.zzyl.member.dto.FamilyMemberDto;
import com.zzyl.member.dto.UserLoginRequestDto;
import com.zzyl.member.service.IFamilyMemberService;
import com.zzyl.member.vo.FamilyMemberVo;
import com.zzyl.member.vo.LoginVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 老人家属Controller
 *
 * @author ruoyi
 * @date 2024-09-02
 */
@RestController
@RequestMapping("/member/user")
@Api(tags = "老人家属相关接口")
public class FamilyMemberController extends BaseController {
    @Autowired
    private IFamilyMemberService familyMemberService;

    @PostMapping("/login")
    @ApiOperation("小程序登录")
    public AjaxResult login(@RequestBody UserLoginRequestDto userLoginRequestDto) {
        LoginVo loginVo = familyMemberService.login(userLoginRequestDto);
        return success(loginVo);
    }

    @PostMapping("/add")
    @ApiOperation("绑定家人")
    public AjaxResult addFamilyMember(@RequestBody FamilyMemberDto familyMemberDto) {
        return familyMemberService.addFamilyMember(familyMemberDto);
    }

/*    @GetMapping("/my")
    @ApiOperation("查询家人列表")
    public AjaxResult getFamilyMemberList() {
        List<FamilyMemberVo> familyMemberList = familyMemberService.getFamilyMemberList();
        return success(familyMemberList);
    }*/

    @GetMapping("/list-by-page")
    @ApiOperation("分页查询家人列表")
    public TableDataInfo getFamilyMemberListByPage(@RequestParam(required = false, defaultValue = "1") Integer pageNum,
                                                   @RequestParam(required = false, defaultValue = "10") Integer pageSize) {
        startPage();
        List<FamilyMemberVo> familyMemberList = familyMemberService.getFamilyMemberList();
        return getDataTable(familyMemberList);
    }

}